package Features
{
	import com.greensock.TweenLite;
	
	import flash.display.MovieClip;
	
	import org.SuiComponents.ScreenLockers.FlatScreenLocker;
	import org.SuiComponents.SuiImage;
	
	public class EggPeiceScreenLocker extends FlatScreenLocker
	{
		private var mcLogo:SuiImage;
		
		public function EggPeiceScreenLocker(_color:uint=0, _alpha:Number=1.0, _animDuration:Number=0.8)
		{
			super( 0, 1.0, 0.8 );
			
			mcLogo	=	new SuiImage();
			mcLogo.setSize( 144, 144 );
			mcLogo.setSWFSource( Assets.assetsSwfName, "logo" );
		}
		
		override protected function onLock( onLockFinish:Function, params:Array ):Boolean
		{
			return super.onLock( function():void
			{
				(mcLogo.source as MovieClip).gotoAndPlay( 1 );
				addChild( mcLogo );
				
				if( onLockFinish != null )
					TweenLite.delayedCall( 1.8, onLockFinish, params );
				
			}, null );
		}
		
		override protected function onUnlock( onUnlockFinish:Function, params:Array ):Boolean
		{			
			removeChild( mcLogo );
			return super.onUnlock( function():void
			{			
				if( onUnlockFinish != null )
					onUnlockFinish.apply( null, params );
				
			}, null);
		}
		
		override protected function onUpdateScreen(stageW:int, stageH:int):void
		{
			mcLogo.x	=	(stageW - mcLogo.width) / 2.0;
			mcLogo.y	=	(stageH - mcLogo.height) / 2.0;
			
			super.onUpdateScreen( stageW, stageH );
		}
	}
}


